import { defineStore } from 'pinia'
// 第一个参数模块名称（key)，用来区分是哪个模块
export const useDemoStore = defineStore('demo', {
    persist: {
        enabled: true,
        strategies: [
            {
                // 缓存的模块名称
                key: "demo",
                // 保存位置，默认保存在sessionStorage
                storage: localStorage,
                // 缓存哪些状态
                paths: ["name"]
            }
        ]
    },
    state: () => {
        return {
            name: '张三',
            msg: "hello demo",
            age: 18,
        }
    },
    getters: {},
    actions: {
        changeName(newName) {
            this.name = newName;
        }
    }
})